package flyingpig.servlet;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import com.thoughtworks.xstream.XStream;

import flyingpig.data.domain.ImageInfo;

public class XStreamlocalTest {

	public static void main(String[] args) {
		String path = "D:/1.txt";
		String content = "";
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(path));
			String line;
			while ((line = reader.readLine()) != null) {
				content += line + "\n";
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		
		XStream xo = new XStream();
		xo.alias("ImageInfo",ImageInfo.class);
		int count = 0;
		String[] ii_xmls = content.split("<Seperator/>");
		for (String xml : ii_xmls) {
			if (!xml.trim().equals("")) {
				System.out.println(xml);
				ImageInfo ii = (ImageInfo) xo.fromXML(xml);
				System.out.println(ii.getUrl());
				// 有没有相同的image存在

				count++;
			}
		}
	}
}